function ConfigAssistant() {
	// urls for services
	this.bosh = '/xmpp-httpbind';
	this.register = '/epic/users';

	// model for list
	this.serverChoices = {
		label: 'server',
		modelProperty: 'value',
		choices: [
			{ label: 'hendl', value: 'blindeshendl.cg.tuwien.ac.at' },
			{ label: 'psi', value: '10.0.2.2' }
		]
	};
	var choice = this.serverChoices.choices[0];
	this.serverModel = { value: utils.get('service') || choice.value };
	this.registerModel =  { label: 'Register '};
}

ConfigAssistant.prototype.onRegister = function() {
	say('onRegister');
	var c = this.controller;
	var url = 'http://' + this.serverModel.value + this.register;
	var req = new Ajax.Request(url, {
		method: 'post'
	});
	c.get('button').mojo.activate();
};

ConfigAssistant.prototype.onConnected = function() {
	var c = this.controller;
	this.btnModel.label = 'Logout';
	c.get('button').mojo.deactivate();
	c.modelChanged(this.btnModel);
	xmpp.unbind('CONNECTED',this.onConnected);
};
ConfigAssistant.prototype.onDisconnected = function() {
	var c = this.controller;
	this.btnModel.label = 'Connect';
	c.get('button').mojo.deactivate();
	c.modelChanged(this.btnModel);
	xmpp.unbind('DISCONNECTEd');
};
ConfigAssistant.prototype.onServerListChanged = function() {
	var c = this.controller;
	var v = this.serverModel.value;
	var choices = this.serverChoices.choices;
	for (var i =0; i < choices.length; i++) {
		if (v === choices[i].value) {
			var l = choices[i].label;
			this.jidModel.value = this.jidModel.value.replace(/@.*/,'@' + l);
			this.adminModel.value = this.adminModel.value.replace(/@.*/,'@' + l);
			c.modelChanged(this.jidModel);
			c.modelChanged(this.adminModel);
		}
	}
};

ConfigAssistant.prototype.setup = function() {
	say('setting up config scene');
	var c = this.controller;
	var e = Mojo.Event;
	c.setupWidget('serverList',this.serverChoices, this.serverModel);
	c.setupWidget('button', { type: Mojo.Widget.activityButton }, this.btnModel );
	c.setupWidget('jid', {}, this.jidModel);
	c.setupWidget('admin', {}, this.adminModel);
	c.setupWidget('destroy', {}, { label: 'destroy '});
	e.listen(c.get('button'), e.tap, this.onButton.bind(this));
	e.listen(c.get('destroy'), e.tap, this.onDestroy.bind(this));
	e.listen(c.get('serverList'), e.propertyChange, this.onServerListChanged.bind(this));
	utils.addMenu(c);
};

ConfigAssistant.prototype.onDestroy = function() {
	say('onDestroy');
	var c = this.controller;
	utils.destroy();
};

ConfigAssistant.prototype.activate = function(event) {
	/* put in event handlers here that should only be in effect when this scene is active. For
	 example, key handlers that are observing the document */

};

ConfigAssistant.prototype.deactivate = function(event) {
	/* remove any event handlers you added in activate and do any other cleanup that should happen before
	   this scene is popped or another scene is pushed on top */
};

ConfigAssistant.prototype.cleanup = function(event) {
	/* this function should do any cleanup needed before the scene is destroyed as 
	   a result of being popped off the scene stack */
};
